import requests
if __name__=="__main__":
    try:
        # url
        url = "http://127.0.0.1:8002/predict"
        # 输入句子
        input_data = {"sentence":"超一流玩家必玩 黑神话孙悟空上线"}
        # 调用flask api
        response = requests.post(
            url,
            json=input_data
        )
        # 检查请求是否成功
        response.raise_for_status()
        # 解析API响应
        result = response.json()
        if 'predicted_label' in result:
            print(f"预测结果：{result['predicted_label']}")
        else:
            print("返回结果不符合条件")
    except requests.exceptions.RequestException as e:
        print(f"无法连接到API：{str(e)}")

